package de.tudarmstadt.gdi1.project;

import java.util.Collection;
import java.util.List;

import de.tudarmstadt.gdi1.project.alphabet.Alphabet;
import de.tudarmstadt.gdi1.project.alphabet.Dictionary;
import de.tudarmstadt.gdi1.project.alphabet.Distribution;
import de.tudarmstadt.gdi1.project.analyse.BacktrackingAnalyse;
import de.tudarmstadt.gdi1.project.analyse.ChoosenAndKnownPlaintext;
import de.tudarmstadt.gdi1.project.analyse.DictionaryTool;
import de.tudarmstadt.gdi1.project.FrequencyDistribution;
import de.tudarmstadt.gdi1.project.analysis.ValidateDecryptionOracle;
import de.tudarmstadt.gdi1.project.analysis.caeser.CaesarCryptanalysis;
import de.tudarmstadt.gdi1.project.analysis.monoalphabetic.Individual;
import de.tudarmstadt.gdi1.project.analysis.monoalphabetic.MonoalphabeticCpaNpaCryptanalysis;
import de.tudarmstadt.gdi1.project.analysis.monoalphabetic.MonoalphabeticCribCryptanalysis;
import de.tudarmstadt.gdi1.project.analysis.monoalphabetic.MonoalphabeticKnownCiphertextCryptanalysis;
import de.tudarmstadt.gdi1.project.analysis.vigenere.VigenereCryptanalysis;
import de.tudarmstadt.gdi1.project.cipher.enigma.Enigma;
import de.tudarmstadt.gdi1.project.cipher.enigma.PinBoard;
import de.tudarmstadt.gdi1.project.cipher.enigma.ReverseRotor;
import de.tudarmstadt.gdi1.project.cipher.enigma.Rotor;
import de.tudarmstadt.gdi1.project.cipher.substitution.SubstitutionCipher;
import de.tudarmstadt.gdi1.project.cipher.substitution.monoalphabetic.Caesar;
import de.tudarmstadt.gdi1.project.cipher.substitution.monoalphabetic.KeywordMonoalphabeticCipher;
import de.tudarmstadt.gdi1.project.cipher.substitution.monoalphabetic.MonoalphabeticCipher;
import de.tudarmstadt.gdi1.project.cipher.substitution.polyalphabetic.PolyalphabeticCipher;
import de.tudarmstadt.gdi1.project.cipher.substitution.polyalphabetic.Vigenere;
import de.tudarmstadt.gdi1.project.substitution.CipherUtils;
import de.tudarmstadt.gdi1.project.substitution.mono.CeasarCipher;
import de.tudarmstadt.gdi1.project.substitution.mono.Monoalphabetic;
import de.tudarmstadt.gdi1.project.substitution.mono.MonoalphabeticKey;
import de.tudarmstadt.gdi1.project.substitution.poly.Polyalphabetic;
import de.tudarmstadt.gdi1.project.substitution.poly.VigenereCipher;
import de.tudarmstadt.gdi1.project.utils.Utils;

public class FactoryIM implements Factory{

	@Override
	public Distribution getDistributionInstance(Alphabet source, String text,
			int ngramsize) {
		Distribution d = new FrequencyDistribution(source, text, ngramsize);
		return d;
	}

	@Override
	public Alphabet getAlphabetInstance(Collection<Character> characters) {
		Alphabet a = new Charset(characters);
		return a;
	}

	@Override
	public Dictionary getDictionaryInstance(Alphabet alphabet, String text) {
		return new DictionaryTool(alphabet, text);
	}

	@Override
	public MonoalphabeticCipher getMonoalphabeticCipherInstance(
			Alphabet source, Alphabet dest) {
		Monoalphabetic a = new Monoalphabetic(source);
		a.setCipherText(dest);
		return a;
	}

	@Override
	public Caesar getCaesarInstance(int key, Alphabet alphabet) {
		return new CeasarCipher(alphabet, key);
	}

	@Override
	public KeywordMonoalphabeticCipher getKeywordMonoalphabeticCipherInstance(
			String key, Alphabet alphabet) {
		MonoalphabeticKey m = new MonoalphabeticKey(alphabet, key);
		return m;
	}

	@Override
	public PolyalphabeticCipher getPolyalphabeticCipherInstance(
			Alphabet source, Alphabet... dest) {
		Polyalphabetic poly = new Polyalphabetic(source);
		poly.setCiphers(dest);
		return poly;
	}

	@Override
	public Vigenere getVigenereCipherInstance(String key, Alphabet alphabet) {
		VigenereCipher cipher = new VigenereCipher(key, alphabet);
		return cipher;
	}

	@Override
	public CaesarCryptanalysis getCaesarCryptanalysisInstance() {
		CaesarCryptanalysis c = new CaesarCipherAnalysis();
		return c;
	}

	@Override
	public MonoalphabeticCpaNpaCryptanalysis getMonoalphabeticCpaNpaCryptanalysis() {
		return new ChoosenAndKnownPlaintext();
	}

	@Override
	public MonoalphabeticCribCryptanalysis getMonoalphabeticCribCryptanalysisInstance() {
		return new BacktrackingAnalyse();
	}

	@Override
	public MonoalphabeticKnownCiphertextCryptanalysis getMonoalphabeticKnownCiphertextCryptanalysisInstance() {
		return null;
	}

	@Override
	public VigenereCryptanalysis getVigenereCryptanalysisInstance() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Utils getUtilsInstance() {
		return new CipherUtils();
	}

	@Override
	public Enigma getEnigmaInstance(List<Rotor> rotors, PinBoard pinboard,
			ReverseRotor reverseRotor) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public PinBoard getPinBoardInstance(Alphabet source, Alphabet destination) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Rotor getRotorInstance(Alphabet entryAlph, Alphabet exitAlph,
			int startPosition) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public ReverseRotor getReverseRotatorInstance(Alphabet entryAlph,
			Alphabet exitAlph) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Class<? extends SubstitutionCipher> getAbstractSubstitutionCipherClass() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public ValidateDecryptionOracle getValidateDecryptionOracle(
			Distribution distribution, Dictionary dictionary) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Individual getIndividualInstance(Alphabet alphabet, double fitness) {
		// TODO Auto-generated method stub
		return null;
	}

}
